package org.vigor.lab.gateway.exception;

import com.netflix.zuul.exception.ZuulException;
import org.springframework.cloud.netflix.zuul.util.ZuulRuntimeException;

import static org.springframework.http.HttpStatus.NON_AUTHORITATIVE_INFORMATION;
import static org.springframework.http.HttpStatus.UNAUTHORIZED;

/**
 * AuthFailException
 * <p>
 * Api 鉴权失败异常
 * </p>
 *
 * @author Vigor Yuan
 */
public class AuthFailException extends ZuulRuntimeException {

    public static final String TOKEN_ERROR = "A1002";

    public static final String TOKEN_NONE = "A1001";

    public AuthFailException(ZuulException cause) {
        super(cause);
    }

    public static AuthFailException TOKEN_ERROR(String msg) {
        return new AuthFailException(new ZuulException(TOKEN_ERROR, UNAUTHORIZED.value(), msg));
    }

    public static AuthFailException TOKEN_NONE(String msg) {
        return new AuthFailException(new ZuulException(TOKEN_NONE, NON_AUTHORITATIVE_INFORMATION.value(), msg));
    }
}
